<?php session_start(); ?>
<div class="<?php if(isset($id)){ echo "msg-fixed"; } ?>">
	<div id="twistTopS" class="topShadow"></div>
	<?php if(is_logged_in() && isMsgVisible($_SESSION['userId'])) { ?> 
		<div class="" style="margin: 0 35px;">
			<div class="msg-head">
				<a href="<?php echo DOMAIN; ?>/message"><h3 class="left"><?php if(isset($id)){ echo "&larr;"; } ?> Messages</h3></a>
				<div class="right">
					<div id="msg-search-wrap" class="left">
						<span class="glass"><i></i></span> 
						<input id="msg-search-btn" type="text" placeholder="Search Message" class="left" />
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	<?php } ?>
</div>
<div class="invitePage" style="margin: 0 35px;">
	<?php
		if(is_logged_in() && isMsgVisible($_SESSION['userId'])) {
			//for a particular conversation: meaning, if the url is of the form www.domain.comn/message/id
			if(isset($id)){
		?>
				<ul class="msg-list" style="background-color: #F1F1F1; padding: 0 30px;">
					<li class="eachLine box" style="font-size: 12px; color: #333;">
						<p class="left" style="margin-right: 5px">Conversation with </p><a href="<?php echo DOMAIN . "/" . conversingWith($id); ?>"><strong><?php echo conversingWith($id); //$id = msgid ?></strong></a>
						<div class="clear"></div>
					</li>
					<?php echo showConversation($id); ?>
				</ul>
		<?php } else { ?>
			<ul class="msg-list">
				<?php echo showsendmsg($_SESSION['userId'], 25); ?>
			</ul>
	<?php } 
		} else {
			if(is_logged_in()){
	?>
		<div style="min-height: 400px; margin: 35px; ">
			<a href="<?php echo DOMAIN; ?>/message"><h3 class="left">Messages</h3></a><br/><br/><br/>
			<div>You have not messages.</div>
		</div>
	<?php 	} else { ?>
		<div style="min-height: 400px; margin: 35px;">
			<p>You need to sign in and have the right access to view this page.</p>
		</div>
	<?php	} 
		}
	?>
	<div class="clear"></div>
</div>
<div class="<?php if(isset($id)){ echo "msg-fixed"; } ?>">
	<?php if(is_logged_in() && isMsgVisible($_SESSION['userId']) && isset($id)) { ?> 
		<div class=""  style="margin: 0 35px;">
			<form id="sendMsgFrm" style="text-align: left;">
				<img src="<?php echo DOMAIN; ?>/img/ajaxLoader.gif" class="loader hide" style="top: 15px; position: relative; left: 5px;"/>
				<div class="lFormItem">
					<textarea id="msg-content" style="margin-left: 35px; width: 440px; height: 50px;" name="msg-to" class="regInputItem ghost_text lFormInput left" placeholder="Message" type="text" tabindex=2 ></textarea>
					<button id="msg-sendid" type="button" class="btnB left" data-msgid="<?php echo $id; ?>" style="margin-left: 5px; margin-bottom: 15px;">Send</button>
					<div class="clear"></div>
					<div class="errorMsg hide clear rError" style="padding: 5px; color: #333; font-size: 11px; width: 443px; margin-left: 35px;" >
						<span class="errorMsg hide rError">Message cannot be more than 500 characters.</span>
					</div>
					<div class="clear" style="margin-bottom: 30px;"></div>
				</div>
			</form>
			<div class="clear"></div>
		</div>
	<?php } ?>
	<div id="twistBottomS" class="bottomShadow"></div>
</div>
<?php

?>